package com.fc.redap.service.impl;

import com.fc.redap.dao.MenuDao;
import com.fc.redap.entity.MenuEntity;
import com.fc.redap.service.IMenuService;
import com.fc.redap.service.IUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl extends BaseServiceImpl<MenuEntity> implements IMenuService {

    @Autowired
    private MenuDao menuDao;

    @Autowired
    private IUserRoleService userRoleService;

    public MenuDao getDao(){
        return menuDao;
    }

    @Override
    public List<MenuEntity> queryByRoleIds(List<Long> roleIds) {
        return menuDao.queryByRoleIds(roleIds);
    }

    @Override
    public List<MenuEntity> queryByUserIds(Long userId) {
        List<Long> roleIds = userRoleService.queryRoleIdList(userId);
        if (roleIds != null && roleIds.size()>0){
            return menuDao.queryByRoleIds(roleIds);
        }else{
            return null;
        }
    }
}
